﻿using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.FlowManagement;
using NP.BPMReportPlatform.FlowManagement.Dto;
using NP.BPMReportPlatform.RecurringJobs;
using NP.BPMReportPlatform.Reports.ThirdFlow.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.Reports.ThirdFlow
{
    /// <summary>
    /// 三方流程 通用查询报表
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/ThirdFlowCommon")]
    public class ThirdFlowCommonController : BPMReportPlatformController
    {
        private readonly IThirdFlowCommonService _service;

        public ThirdFlowCommonController(IThirdFlowCommonService service)
        {
            _service = service;
        }

        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("GetAllAsync")]
        public async Task<PagedResultDto<GetThirdFlowCommonOutput>> GetAllAsync([FromBody] GetThirdFlowCommonInput input)
        {
            return await _service.GetAllAsync(input);
        }

        /// <summary>
        /// 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("ExportAsync")]
        public async Task<XlsxFileResult<GetThirdFlowCommonOutput>> ExportAllAsync([FromBody] GetThirdFlowCommonInput input)
        {
            var rst = await _service.ExportAsync(input);
            return new XlsxFileResult<GetThirdFlowCommonOutput>(rst, "导出Excel");
        }

        /// <summary>
        /// 回调
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("ThirdFlowCallBack")]
        public async Task<string> ThirdFlowCallBack([FromBody] ThirdFlowCallBakInput input)
        {
            return await _service.ThirdFlowCallBack(input);
        }

        /// <summary>
        /// 作废
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("ThirdFlowCancel")]
        public async Task<string> ThirdFlowCancel([FromBody] ThidFlowOpreaterInput input)
        {
            return await _service.ThirdFlowCancel(input);
        }

        /// <summary>
        /// 撤回
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("ThirdFlowRecall")]
        public async Task<string> ThirdFlowRecall([FromBody] ThidFlowOpreaterInput input)
        {
            return await _service.ThirdFlowRecall(input);
        }
    }
}
